<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<!-- This code written by Willie Wheeler and John Wheeler -->
<!-- For 'Spring In Practice' [Book written by Willie Wheeler and John Wheeler] -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Register</title>
		<style>
			.form-item { margin: 20px 0; }
			.form-label { font-weight: bold; }
			.form-global-error-message { width: 500px; padding: 6px; background: #E2ABAB; color: #FFF; font-weight: bold; }
			.form-error-message { color: #900; }
			.form-error-field { background-color: #FFC; }
		</style>
		<script type="text/javascript">
			window.onload = function() {
				document.getElementById("firstName").focus();
			}
		</script>
	</head>
	<body>
		<h1>Register</h1>

		<form:form modelAttribute="user">
			<spring:bind path="user">
				<spring:hasBindErrors name="user">
					<div class="form-global-error-message"><form:errors></form:errors></div>
				</spring:hasBindErrors>
			</spring:bind>
			<div class="form-item">
				<div class="form-label">First name:</div>
				<form:input path="firstName" size="40" cssErrorClass="form-error-field"/>
				<div class="form-error-message"><form:errors path="firstName"></form:errors></div>
			</div>
			<div class="form-item">
				<div class="form-label">Last name:</div>
				<form:input path="lastName" size="40" cssErrorClass="form-error-field"/>
				<div class="form-error-message"><form:errors path="lastName"></form:errors></div>
			</div>
			<div class="form-item">
				<div class="form-label">E-mail address:</div>
				<form:input path="email" size="40" cssErrorClass="form-error-field"/> We won't spam you
				<div class="form-error-message"><form:errors path="email" htmlEscape="false"></form:errors></div>
			</div>
			<div class="form-item">
				<div class="form-label">User name:</div>
				<form:input path="username" size="40" cssErrorClass="form-error-field"/>
				<div class="form-error-message"><form:errors path="username"></form:errors></div>
			</div>
			<div class="form-item">
				<div class="form-label">Password:</div>
				<form:password path="password" showPassword="true" size="40" cssErrorClass="form-error-field"/>
				<div class="form-error-message"><form:errors path="password"></form:errors></div>
			</div>
			<div class="form-item">
				<div class="form-label">Confirm password:</div>
				<form:password path="passwordConfirmation" showPassword="true" size="40" cssErrorClass="form-error-field"/>
				<div class="form-error-message"><form:errors path="passwordConfirmation"></form:errors></div>
			</div>

			You can read our <a href="#">privacy policy</a> in a new window if you'd like.			

			<div class="form-item">
				<input type="submit" value="Register"/>
			</div>
		</form:form>	
	</body>
</html>
